﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Oragon.Architecture.Data.SqlBuilder.Operators
{
	/// <summary>
	/// Representa uma expressão Between
	/// </summary>
	[Serializable]
	public class BetweenOperator : BinaryOperator
	{
		public BetweenOperator() : base(null, null) { }

		public override string Operator
		{
			get { return "BETWEEN"; }
		}

		public ISQLStatement RightStartExpression { get; set; }
		public ISQLStatement RightEndExpression { get; set; }


		public BetweenOperator(ISQLStatement leftExpression, ISQLStatement rightStartExpression, ISQLStatement rightEndExpression)
			: base(leftExpression, null)
		{
			this.RightStartExpression = rightStartExpression;
			this.RightEndExpression = rightEndExpression;
		}

		public override string ToSQL()
		{
			return string.Format(System.Globalization.CultureInfo.InvariantCulture, "( {0} {1} {2} AND {3} )",
				this.LeftExpression.ToSQL(),
				this.Operator,
				this.RightStartExpression.ToSQL(),
				this.RightEndExpression.ToSQL());
		}


	}
}
